#include "stm32f1xx_hal.h"

int Encoder_GetSpeed(TIM_HandleTypeDef *htim)
{
  int Counter = 0;
  Counter = (short)__HAL_TIM_GetCounter(htim); //获取此时定时器的计数值
  __HAL_TIM_SET_COUNTER(htim, 0);              //重新写入计数值0
  return Counter;
}
